added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2010 / CSASPNETCurrentOnlineUserList / CurrentOnlineUserList.aspx.cs
blobab67366558ebbd1fcab453c41a6b75fea4226137
1 /**************************** Module Header ********************************\
2 * Module Name: CurrentOnlineUserList.aspx.cs
3 * Project: CSASPNETCurrentOnlineUserList
4 * Copyright (c) Microsoft Corporation
6 * The Membership.GetNumberOfUsersOnline Method can get the number of online
7 * users,however many asp.net projects are not using membership.This project
8 * shows how to display a list of current online users' information without
9 * using membership provider.
11 * This page is used to display the current online user's information.
13 * This source is subject to the Microsoft Public License.
14 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
15 * All other rights reserved.
17 \***************************************************************************/
19 using System;
20 using System.Web.UI.WebControls;
22 namespace CSASPNETCurrentOnlineUserList
24 public partial class CurrentOnlineUserList : System.Web.UI.Page
26 protected void Page_Load(object sender, EventArgs e)
28 // Check whether the user is login.
29 CheckLogin();
31 public void CheckLogin()
33 string _userticket = "";
34 if (Session["Ticket"] != null)
36 _userticket = Session["Ticket"].ToString();
38 if (_userticket != "")
40 // Initialize the datatable which used to store the information
41 // of current online user.
42 DataTableForCurrentOnlineUser _onlinetable = new DataTableForCurrentOnlineUser();
44 // Check whether the user is online by using ticket.
45 if (_onlinetable.IsOnline_byTicket(this.Session["Ticket"].ToString()))
47 // Update the last active time.
48 _onlinetable.ActiveTime(Session["Ticket"].ToString());
50 // Bind the datatable which used to store the information of
51 // current online user to gridview control.
52 gvUserList.DataSource = _onlinetable.ActiveUsers;
53 gvUserList.DataBind();
55 else
57 // If the current User is not exist in the table,then redirect
58 // the page to LogoOut.
59 Response.Redirect("LogOut.aspx");
62 else
64 Response.Redirect("Login.aspx");